package com.gxa.eshop.repository;


import com.gxa.eshop.pojo.OrderStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * Created by billon 2020/1/7
 **/
public interface OrderStatusRepository extends JpaRepository<OrderStatus,Long> {

    @Query(nativeQuery = true,value = "UPDATE gxa_order_status SET status=?1 WHERE order_id=?2 and status=?3")
    @Modifying
    public Integer changeOrderState(Integer nowStatus, String orderId, Integer oldStatus);

    @Query(nativeQuery = true,value = "select * from gxa_order_status where status=1 and last_pay_time<?1")
    public List<OrderStatus> queryOrderStatusMorePayTime(Date nowDate);

    public OrderStatus findOrderStatusByOrderId(String orderId);

}
